/*********************************************************
 * Cameron Hilton
 * CS362_400
 * 
 * Test to see if game over state properly identified in isGameOver() function
 ********************************************************/

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int main() {
    
    int seed = 1000;
    int numPlayer = 2;
    int supplyPiles = 24;
    int i;
    
	struct gameState state;
	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};

	initializeGame(numPlayer, k, seed, &state);
	
	printf("Testing initial state\n");
	assert(isGameOver(&state) == 0); // initial game state should not result in game being over

	printf("Testing no more province cards\n");
	memset(&state, 23, sizeof(struct gameState)); // reset game state
	state.supplyCount[province] = 0;
	assert(isGameOver(&state) == 1); // no remaining provinces = game over

	// test supply piles being empty
	memset(&state, 23, sizeof(struct gameState)); // reset game state

	for (i = 0; i <= supplyPiles; i++) {
		printf("Testing %d empty supply piles\n", i);
		state.supplyCount[i] = 0;
		if (i < 2)
			assert(isGameOver(&state) == 0); // less than 3 exhausted piles
		else
			assert(isGameOver(&state) == 1); // 3 or more exhausted piles			
	}

    printf("All tests passed!\n");

    return 0;
}